package mycontrol;
/**
 * 自定义控件
 * 绘制几何形状，矩形，椭圆，扇形（以及描边）
 *         g.fillRect(x,y,width,height);
 *         g.fillOval();
 *         g.fillArc();
 *         g.drawRect();
 *         g.drawOval();
 *         g.drawArc();
 */

import javax.swing.*;
import java.awt.*;

public class MyControl extends JPanel {
    @Override
    protected void paintComponent(Graphics g) {
        super.paintComponent(g);
        //获得控件的高度和宽度
        int height = this.getHeight();
        int width = this.getWidth();

        //setColor(r,g,b,透明度)
        //绘制几何形状
        g.setColor(new Color(205,200,120,128));
        g.fillRect(0,0,width,height);
        g.setColor(Color.CYAN);
        g.drawRect(0,0,width,height);


    }
}
